<template>
	<view class="min100" style="">
		<view class="">
			<!-- 头部 -->
			<view class="diamondMall_head p20 flex-between flex1"
				:style="[{ background: bg_color},{paddingTop:blindBoxheight+'rpx'}]">
				<view class="">
					<image class="ml-30" src='../../static/chip/back.png' mode="widthFix" style="width: 30rpx;"
						@click="backmarket()"></image>
				</view>
				<view class="size-30 center" :style="{opacity:textcolor}">
					{{info.name}}
				</view>
				<view class="">
					<!-- 
					<image class="collection"
						:src="info.is_focus==0?'../../static/home/aixinold.png':'../../static/home/aixinnew.png'"
						v-show="showUpImg" @click="changeImg" style="width: 40rpx;height: 40rpx;">
					</image>

					<image class="collection"
						:src="info.is_focus==1?'../../static/home/aixinold.png':'../../static/home/aixinnew.png'"
						v-show="!showUpImg" @click="changeImg" style="width: 40rpx;height: 40rpx;">
					</image> -->
					<!-- ../../static/home/aixinold.png -->
				</view>
			</view>
			<view class="topWrap  " style="">
				<image class="home_detail_bg" src="../../static/index/detail_bg.jpg" mode=""></image>
				<img :src="info.images" class="collectImg">

				<view class="autrhorinfo  radius-20  size-40 ">
					<view class="flex1 flex-between">
						<view class="white" style="">
							￥{{info.price}}
						</view>
						<view class="flex1 white size-26">
							<view class="">
								其他寄售
							</view>
							<view class="">
								<u-icon name="arrow-right"></u-icon>
							</view>
						</view>
					</view>
					<view class="detail_name" style="color: #000;">
						<view class="">
							{{info.name}}
						</view>
						<view class="" style="display: flex;">
							<view class="" style="display: flex;margin: 40rpx 40rpx 0 0;">
								<view class="homedetail_limit_1">
									限量
								</view>
								<view class="homedetail_limit_2">
									{{info.stock}}份
								</view>
							</view>
							<view class="" style="display: flex;margin: 40rpx 40rpx 0 0;">
								<view class="homedetail_limit_1">
									流通
								</view>
								<view class="homedetail_limit_2">
									{{info.surplus}}份
								</view>
							</view>
						</view>
					</view>
					<view class="" style="display: flex;justify-content: space-between;width: 100%;">
						<view class="honmedetail_three" @click="goBrandside(goods_category_id,id)">
							<view class="">
								<image src="../../static/home/pinpaifang.png" mode="widthFix" style="width: 80rpx;">
								</image>
							</view>
							<view class="" style="display: flex;margin: 10rpx 0 0 0;">
								<view class="" style="width: 50rpx;height: 50rpx;">
									<image :src="info.goods_category_image" mode=""
										style="width: 100%;height: 100%;border-radius: 50%;"></image>
								</view>
								<view class=""
									style="display: flex;width: 220rpx;justify-content: space-between;align-items: center;margin: 0 0 0 20rpx;">
									<view class="goods_category_name">
										{{info.goods_category_name}}
									</view>
									<view class="">
										<u-icon name="arrow-right"></u-icon>
									</view>
								</view>
							</view>
						</view>
						<view class="honmedetail_three" @click="goCreator(author_id,id)">
							<view class="">
								<image src="../../static/home/author.png" mode="widthFix" style="width: 80rpx;"></image>
							</view>
							<view class="" style="display: flex;margin: 10rpx 0 0 0;">
								<view class="" style="width: 50rpx;height: 50rpx;">
									<image :src="info.author_image" mode=""
										style="width: 100%;height: 100%;border-radius: 50%;"></image>
								</view>
								<view class=""
									style="display: flex;width: 220rpx;justify-content: space-between;align-items: center;margin: 0 0 0 20rpx;">
									<view class="author">
										{{info.author_name}}
									</view>
									<view class="">
										<u-icon name="arrow-right"></u-icon>
									</view>
								</view>
							</view>
						</view>
					</view>
					
					<view class="album">
						<view class="flex_between album_box">
							<view class="">
								所属专辑
							</view>
							<view class="">
								{{info.network_name}}
							</view>
						</view>
						<view class="flex_between album_box1 album_box ">
							<view class="">
								合约地址
							</view>
							<view class="flex">
								<view class="" style="margin: 0 10rpx 0 0rpx;">
									{{info.meta_data}}
								</view>
								<view class="" style="width: 25rpx;height: 25rpx;">
									<image @click=copy(userInfo.wallet_address) src="../../static/my/fuzhi.png" mode=""
										style="width: 100%;height: 100%;"></image>
								</view>
							</view>
						</view>
			<!-- 			<view class="flex_between album_box">
							<view class="">
								认证标识
							</view>
							<view class="">
								{{info.network_name}}
							</view>
						</view>
						<view class="flex_between album_box">
							<view class="">
								拥有者
							</view>
							<view class="">
								{{info.network_name}}
							</view>
						</view> -->

						<view class="" style="margin: 20rpx 0 0 0;">
							<image src="../../static/home/cangpingushi.png" mode="widthFix" style="width: 140rpx;">
							</image>
						</view>

						<view class="size-22 mt-20">
							<u-parse :content="content" @preview="preview" @navigate="navigate"></u-parse>
						</view>
						<view class="size-22 mt-20 " style="padding-bottom: 200rpx;">
							<u-parse :content="buy_content" @preview="preview" @navigate="navigate"></u-parse>
						</view>

					</view>

				</view>

			</view>

		</view>
		<view class="btmWrap flex pt-30 flex-between plr-30 pb-30">
			<!-- <view class="nonebtn" v-if="info.status==2">首发售空</view> -->
			<view class=" size-50 bold">
				￥{{info.price}}
			</view>
			<!-- <u-number-box v-model="value" @change="valChange"></u-number-box> -->
			<view class="">
				<button class="mtb-30 buyBtn " style="color: #fff;" hover-class="none" @click="toBuy"
					:disabled="btnDisabled" v-if="info.status==1">立即购买</button>
				<view class="itemTips plr-40 ptb-8 detail_bottom_price" v-if="info.status==2">
					{{info.status_text}}
				</view>
				<view class="radius-40 plr-40 ptb-8 text-center" v-if="info.status==3"
					style="color:#9fc58c;background:#161912;">
					<view class="">
						{{info.status_text}}
					</view>
					<view class="mt-10">
						{{info.status_time_text}}
					</view>
				</view>
				<view class="itemTips radius-40 plr-40 text-center ptb-8" v-if="info.status==4">
					<view class="">
						{{info.status_text}}
					</view>
					<u-count-down :timestamp="info.diff_time" bg-color="background:transparent" color="#333"
						font-size="24" separator-color="#333" style="margin-left:5rpx"></u-count-down>
				</view>
			</view>
		</view>
		<!-- 预览图片 -->
		<u-popup v-model="preShow" mode='center' border-radius='20'>
			<view>
				<img :src="info.images" class="collectPreImg">
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		globalData
	} from "@/App.vue"
	import uParse from '@/components/u-parse/u-parse.vue'
	export default {
		components: {
			uParse
		},
		data() {

			return {
				blindBoxheight: '',
				is_focus: '',
				showUpImg: true,
				textcolor: '0',
				bg_color: '',
				buy_content: '',
				content: '',
				btnDisabled: false,
				preShow: false,
				id: "",
				info: {}
			}
		},
		onLoad(options) {
			console.log(options);
			this.id = options.goods_id;
			console.log(this.id);
			this.$http('api/orders/goodsOrderDetailNew', {
				goods_id: this.id
			}).then(res => {
				this.info = res;
				console.log(this.info);
				this.is_focus = this.info.is_focus
				this.goods_category_id = this.info.goods_category_id
				this.author_id = this.info.author_id
				this.content = res.content
				this.buy_content = res.buy_content
			})
			let _that = this;
			uni.getSystemInfo({
				success(e) {
					console.log(e.statusBarHeight, '123122222222222222222222');
					if (e.platform == "ios" || e.platform == "devtools") {
						_that.blindBoxheight = e.statusBarHeight + 45;
					} else {
						_that.blindBoxheight = e.statusBarHeight + 50;
					}
				}
			})
			console.log(getApp().globalData);
		},
		onShow() {

		},
		// 吸顶
		onPageScroll(e) {
			let h = e.scrollTop
			if (h >= 0) {
				if (h <= 0) {
					this.bg_color = ''
					this.textcolor = '0'
				} else if (20 < h && h <= 200) {
					this.bg_color = '#fff'
					this.textcolor = "100%"
				} else if (h > 300) {
					this.bg_color = '#fff'
					this.textcolor = "100%"
				}
			}
			// console.log(this.textcolor);
			//#ifdef H5
			this.isF = true
			// #endif
			// #ifndef H5
			if (this.yuanH > e.scrollTop) {
				this.isF = false
			} else {
				this.isF = true
			}
			// #endif
		},
		methods: {
			changeImg() {
				console.log(this.showUpImg);
				this.showUpImg = !this.showUpImg
				this.$http('api/user/userFocus', {
					goods_id: this.id,
					type: 0
				}, 'POST').then(res => {
					console.log(res.msg);
					uni.showToast({
						title: res.msg,
					})
				});

			},
			backmarket() {
				uni.navigateBack({
					url: '/pages/home/index'
				})
			},
			// 品牌方
			goBrandside(goods_category_id, id) {
				// uni.navigateTo({
				// 	url: "/pages/home/detailBrandside?goods_category_id=" + goods_category_id + '&id=' + id
				// })
			},
			// 创作者
			goCreator(author_id, id) {
				// uni.navigateTo({
				// 	url: "/pages/home/homeCreator?author_id=" + author_id + '&id=' + id
				// })
			},
			copy(val) {
				// #ifdef APP-PLUS
				uni.setClipboardData({
					data: val,
					success: function() {
						uni.hideToast();
						uni.getClipboardData({
							success: function(res) {
								uni.showToast({
									title: '区域链地址复制成功',
									icon: 'none'
								});
							}
						});
					}
				});
				// #endif
				// #ifdef H5
				this.$copyText(val).then(
					function(e) {
						console.log(val, e);
						uni.showToast({
							title: '区域链地址复制成功!',
							icon: 'none'
						});
					},

				);
				// #endif
			},
			// 回退首页
			gobackhome() {
				uni.navigateBack({
					url: '../home/index'
				})
			},
			valChange(e) {
				// console.log('当前值为: ' + e.value)
			},
			handlePre() {
				uni.navigateTo({
					url: './homeShow?url=' + this.info.model_url
				})
			},
			// 预览图片
			toBuy() {
				// this.btnDisabled=true;
				// this.$http('api/orders/goodsApply', {
				// 	id: this.id,
				// 	num:this.value

				// }).then(res => {
				// 	this.btnDisabled=false;
				// 	uni.navigateTo({
				// 		url: '../pay/collectPay?order_id=' + res.order_id
				// 	})
				// })
				this.btnDisabled = true;
				this.$http('api/user/isTradePass', {}).then(res => {
					if (res.is_trade == 0) { //判断是否设置过密码
						console.log('去设置密码')
						uni.showModal({
							title: '提示',
							content: '还未设置密码，去设置密码',
							success: function(res) {
								if (res.confirm) {
									uni.navigateTo({
										url: './password'
									});
								} else if (res.cancel) {}
							}
						});
					} else if (res.is_trade == 1) {
						this.$http('api/orders/goodsApply', {
							id: this.id,
							num: this.value
						}).then(res => {
							this.btnDisabled = false;
							uni.navigateTo({
								url: '../pay/collectPay?order_id=' + res.order_id
							})
						})
					}
				})
			},
			// 复制
			copyAddress(val) {
				// #ifdef APP-PLUS
				uni.setClipboardData({
					data: val,
					success: function() {
						uni.hideToast()
						uni.getClipboardData({
							success: function(res) {
								uni.showToast({
									title: '复制成功',
									icon: 'none'
								})
							}
						});
					}
				});
				// #endif
				// #ifdef H5
				let that = this;
				this.$copyText(val).then(function(e) {
					uni.showToast({
						title: "复制成功!",
						icon: "none"
					})
				}, function(e) {
					uni.showToast({
						title: "复制失败!",
						icon: "none"
					})
				})
				// #endif
			},
		}
	}
</script>

<style lang="less" scoped>
	.album_1 {
		border: 2rpx solid #EBEBEB;
		height: 60rpx;
	}

	.goods_category_name {
		width: 600rpx;
		height: auto;
		word-wrap: break-word;
		/*强制换行*/
		overflow: hidden;
		/*超出隐藏*/
		text-overflow: ellipsis;
		/*隐藏后添加省略号*/
		white-space: nowrap;
		/*强制不换行*/
	}

	.author {
		width: 600rpx;
		height: auto;
		word-wrap: break-word;
		/*强制换行*/
		overflow: hidden;
		/*超出隐藏*/
		text-overflow: ellipsis;
		/*隐藏后添加省略号*/
		white-space: nowrap;
		/*强制不换行*/

	}

	.diamondMall_head {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 1000;
		width: 100%;
		height: 100rpx;
		background-image: #FFF;
	}

	.detail_bottom_price {
		width: 490rpx;
		height: 70rpx;
		text-align: center;
		font-size: 24rpx;
		line-height: 70rpx;
		color: #FFF;
		border-radius: 15rpx;
	}

	.purchase {
		color: #5C5C5C;
		font-size: 22rpx;
	}

	.album_box {
		border-bottom: 2rpx solid #EBEBEB;
		height: 60rpx;
	}

	.album_box1 {
		height: 60rpx;
		margin: 20rpx 0 0 0;
	}

	.album {
		color: #000;
		width: 690rpx;
		height: 160rpx;
		// border: 2rpx solid #EBEBEB;
		border-radius: 20rpx;
		margin: 30rpx 0 0 -30rpx;
		font-size: 27rpx;
		padding: 20rpx;

	}

	.honmedetail_three {
		color: #000;
		width: 330rpx;
		height: 130rpx;
		border: 2rpx solid #EBEBEB;
		border-radius: 20rpx;
		margin: 30rpx 0 0 -30rpx;
		font-size: 27rpx;
		padding: 20rpx;
	}

	.homedetail_limit_1 {
		width: 100rpx;
		height: 40rpx;
		background-color: #F5BA76;
		text-align: center;
		line-height: 40rpx;
		font-weight: 500;
		// font-family: cursive;
		font-size: 26rpx;
	}

	.homedetail_limit_2 {
		// width: 100rpx;
		height: 40rpx;
		background-color: #F9EFE5;
		text-align: center;
		line-height: 40rpx;
		font-size: 12rpx;
		color: #AB6E28;
		padding: 0 6rpx;
	}

	.detail_name {
		background-color: #FFF;
		color: rgb(0, 0, 0);
		width: 690rpx;
		height: 200rpx;
		border-radius: 22rpx;
		margin: 20rpx 0 0 -30rpx;
		padding: 24rpx;
		font-size: 30rpx;
		border: 2rpx solid #EBEBEB;
	}

	.flex_around {
		display: flex;
		justify-content: space-around;
	}

	.flex_between {
		display: flex;
		justify-content: space-between;
	}

	.flex {
		display: flex;
	}

	.home_detail_bg {
		width: 100%;
		// height: 950rpx;
		height: 91%;
		position: absolute;
		left: 0;
		top: -40rpx;
		z-index: -1;

	}

	.userImg {
		width: 60rpx;
		height: 60rpx;
		border-radius: 50%;
	}

	.buyBtn {
		font-size: 28rpx;
		color: #040404;
		line-height: 80rpx;
		height: 80rpx;
		background: #44ACFF;
		border-radius: 40rpx;
		width: 210rpx;
	}


	.copyImg {
		width: 24rpx;
		height: 24rpx;
	}

	.btmWrap {
		position: fixed;
		z-index: 10;
		width: 100%;
		bottom: 0;
		background: #fff;

		.nonebtn {
			width: 90%;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 50rpx;
			background-color: rgba(#714aed, .4);
			margin: 0 auto;
			text-align: center;
			color: #fff;
		}
	}

	.tipsLeft {
		background: #44ACFF;
		color: #2f2f2e;
	}

	.collectImg {
		width: 86%;
		display: block;
		margin: 0px auto;
		height: auto;
		position: relative;
		border-radius: 7%;
		top: 160rpx;
		border: 20rpx solid #FFF;
	}

	.tipsRight {
		background: rgba(239, 170, 28, .3);
	}

	.topWrap {
		// padding-top: 120rpx;
		// background: url(../../static/detailsBg.png) 0 0 no-repeat;
		background-size: 100% 100%;
		// background-color: #FFF;
		width: 100%;
		position: relative;

		.autrhorinfo {
			width: 92%;
			background-color: #FFF;
			margin: 180rpx auto;
			background-image: linear-gradient(to right, #636363, #2B2B2B);
			height: 270rpx;
			padding: 30rpx;


		}
	}


	.infoWrap {
		color: #fff;

		::v-deep  img {
			width: 100% !important;
			height: auto;
		}
	}

	.itemTips {
		font-size: 28rpx;
		background: #DEE4E8 !important;
		// border-radius: 40rpx;
	}

	.topContent {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 30rpx;
		z-index: 10;
		width: 100%;
		text-align: center;
	}
</style>
